#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QString>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    _timer = new QTimer(this);
}

Widget::~Widget()
{
    delete ui;
}


//增加
void Widget::on_pushButton_add_clicked()
{
    ui->label_tip->clear();
    QString info = ui->lineEdit->text();
    if(info.size() == 0)
    {
        qDebug()<<"lineEdit内容为空！";
        return;
    }
    ui->listWidget->addItem(info);
    ui->lineEdit->clear();
}
void Widget::on_listWidget_currentRowChanged(int currentRow)
{
    QListWidgetItem* obj = ui->listWidget->item(currentRow);
    qDebug()<<"您选中的是:"<<obj->text();
}


void Widget::on_pushButton_del_clicked()
{
     int row = ui->listWidget->currentRow();
     if(ui->listWidget->count() == 1)
     {
         ui->label_tip->setText("提示：至少要保留一行!");
         return;
     }
     ui->listWidget->takeItem(row);
     qDebug()<<"删除成功!";
}

